package com.zmyuan.quartz.ram.demo.cron;

import org.quartz.CronExpression;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by zhudebin on 2017/2/25.
 */
public class CronExpDemo {

    public static void main(String[] args) throws Exception {

        testMonthCron();

    }

    public static void testMonthCron() throws Exception {
        String cronExp = "30 40 17 2 * ? *";
        CronExpression expression = new CronExpression(cronExp);
        Date date = new Date();
        for(int i=0; i<5; i++) {
            date = expression.getNextValidTimeAfter(date);

            printDate(date);
        }
    }

    public static void printDate(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(date));
    }
}
